
//------------------------------------------------------------------------------
// The confidential and proprietary information contained in this file may
// only be used by a person authorised under and to the extent permitted
// by a subsisting licensing agreement from ARM Limited.
//
//            (C) COPYRIGHT 2008-2012 ARM Limited.
//                ALL RIGHTS RESERVED
//
// This entire notice must be reproduced on all copies of this file
// and copies of this file may only be made by a person if such person is
// permitted to do so under the terms of a subsisting license agreement
// from ARM Limited.
//------------------------------------------------------------------------------
// Version and Release Control Information:
//
// File Revision       : 149904
// File Date           :  2009-05-01 11:37:44 +0100 (Fri, 01 May 2009)
// Release Information : PL401-r0p1-00eac0
//------------------------------------------------------------------------------
// Purpose : This module determines the source of the apb transfer
//------------------------------------------------------------------------------

module apb_aux
(
    pid,
    pstrobe
);   

//------------------------------------------------------------------------------
// Parameter declarations
//------------------------------------------------------------------------------  

   parameter INSTANCE = "undef"; //not used placeholder for consistancy
   parameter ID_WIDTH = 16;

//------------------------------------------------------------------------------
// Port declarations
//------------------------------------------------------------------------------

   output [ID_WIDTH-1:0]      pid;       //ID of the incoming transaction
   output [3:0]               pstrobe;   //Strobes value of the incoming transaction

//------------------------------------------------------------------------------
// wire declarations 
//------------------------------------------------------------------------------  

   
   wire [ID_WIDTH-1:0] pid_tpv_gp_apb4;
   wire [3:0] pstrobe_tpv_gp_apb4;
   
   wire [ID_WIDTH-1:0] pid_perip0_gp_apb4;
   wire [3:0] pstrobe_perip0_gp_apb4;
   
   wire [ID_WIDTH-1:0] pid_perip1_gp_apb4;
   wire [3:0] pstrobe_perip1_gp_apb4;
   
   wire [ID_WIDTH-1:0] pid_sys_gp_apb4;
   wire [3:0] pstrobe_sys_gp_apb4;
   
   wire [ID_WIDTH-1:0] pid;

//------------------------------------------------------------------------------
// code declarations 
//------------------------------------------------------------------------------  
    
   

//Determine the id of the current transaction
`ifdef ARM_NET_SIM
   
   assign pid_tpv_gp_apb4 = {ID_WIDTH{1'b0}};
   assign pid_perip0_gp_apb4 = {ID_WIDTH{1'b0}};
   assign pid_perip1_gp_apb4 = {ID_WIDTH{1'b0}};
   assign pid_sys_gp_apb4 = {ID_WIDTH{1'b0}};
`else
   
   assign pid_tpv_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_25m.u_amib_tpv_gp_apb4.u_apb_m.axi_id;
   assign pid_perip0_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_100m.u_amib_perip0_gp_apb4.u_apb_m.axi_id;
   assign pid_perip1_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_100m.u_amib_perip1_gp_apb4.u_apb_m.axi_id;
   assign pid_sys_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_100m.u_amib_sys_gp_apb4.u_apb_m.axi_id;
`endif

   assign pid = (INSTANCE == "uart_slv_apb4_tpv") ?  pid_tpv_gp_apb4 :
                (INSTANCE == "spfs_slv_apb4_tpv") ?  pid_tpv_gp_apb4 :
                (INSTANCE == "gpio_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "uart_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "pwm0_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "i2c_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "qspi_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "archinfo_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "crc_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "spi0_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "spi1_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "clint_slv_apb4") ?  pid_sys_gp_apb4 :
                (INSTANCE == "plic_slv_apb4") ?  pid_sys_gp_apb4 :
                (INSTANCE == "rcu_slv_apb4") ?  pid_sys_gp_apb4 :
                (INSTANCE == "ps2_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "rng_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "tim0_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "tim1_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "tim2_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "tim3_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "psram_slv_apb4") ?  pid_perip1_gp_apb4 :
                (INSTANCE == "rtc_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "wdg_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "pwm1_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "pwm2_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "vgalcd_slv_apb4") ?  pid_perip0_gp_apb4 :
                (INSTANCE == "i2s_slv_apb4") ?  pid_tpv_gp_apb4 :
                 {ID_WIDTH{1'b0}};

`ifdef ARM_NET_SIM
   
   assign pstrobe_tpv_gp_apb4 = {4{1'b0}};
   assign pstrobe_perip0_gp_apb4 = {4{1'b0}};
   assign pstrobe_perip1_gp_apb4 = {4{1'b0}};
   assign pstrobe_sys_gp_apb4 = {4{1'b0}};
`else
   
   assign pstrobe_tpv_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_25m.u_amib_tpv_gp_apb4.u_apb_m.pstrb_i;
   assign pstrobe_perip0_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_100m.u_amib_perip0_gp_apb4.u_apb_m.pstrb_i;
   assign pstrobe_perip1_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_100m.u_amib_perip1_gp_apb4.u_apb_m.pstrb_i;
   assign pstrobe_sys_gp_apb4 = tbench.u_nic400.u_cd_clk_peri_100m.u_amib_sys_gp_apb4.u_apb_m.pstrb_i;
`endif

   assign pstrobe = (INSTANCE == "uart_slv_apb4_tpv") ?  pstrobe_tpv_gp_apb4 :
                (INSTANCE == "spfs_slv_apb4_tpv") ?  pstrobe_tpv_gp_apb4 :
                (INSTANCE == "gpio_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "uart_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "pwm0_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "i2c_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "qspi_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "archinfo_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "crc_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "spi0_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "spi1_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "clint_slv_apb4") ?  pstrobe_sys_gp_apb4 :
                (INSTANCE == "plic_slv_apb4") ?  pstrobe_sys_gp_apb4 :
                (INSTANCE == "rcu_slv_apb4") ?  pstrobe_sys_gp_apb4 :
                (INSTANCE == "ps2_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "rng_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "tim0_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "tim1_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "tim2_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "tim3_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "psram_slv_apb4") ?  pstrobe_perip1_gp_apb4 :
                (INSTANCE == "rtc_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "wdg_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "pwm1_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "pwm2_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "vgalcd_slv_apb4") ?  pstrobe_perip0_gp_apb4 :
                (INSTANCE == "i2s_slv_apb4") ?  pstrobe_tpv_gp_apb4 :
                 {4{1'b0}};


endmodule

